package com.foreknow.controller;

import com.foreknow.po.User;
import com.foreknow.service.Impl.UserServiceImpl;
import com.foreknow.service.UserService;

import javax.servlet.http.HttpServletRequest;

public class UserController{

    public Object getUserByIdByPass(HttpServletRequest request){
        UserService service = new UserServiceImpl();
        String userId = request.getParameter("userId");
        String password = request.getParameter("password");
        User user = service.getUserByIdByPass(userId,password);
        return user;
    }

    public Object getUserById(HttpServletRequest request){
        UserService service = new UserServiceImpl();
        String userId = request.getParameter("userId");
        Integer result = service.getUserById(userId);
        return  result;
    }

    public Object saveUser(HttpServletRequest request){
        UserService service = new UserServiceImpl();
        String userId = request.getParameter("userId");
        String password = request.getParameter("password");
        String userName = request.getParameter("userName");
        int userSex = Integer.parseInt(request.getParameter("userSex"));
        int result = service.saveUser(userId,password,userName,userSex);
        return result;
    }

}
